﻿using System;

using System.Collections.Generic;
using System.Text;

namespace Silvermoon.Controls.Classes
{
    /// <summary>
    /// Cell specifies an area of rows and columns in a <see cref="T:Grid"/.
    /// </summary>
    public class GridCell
    {
        #region fields
        private int alpha = 255;

        #endregion
        #region ctor

        public GridCell()
            : base()
        {
            RowSpan = 1;
            ColSpan = 1;
            ResizeMode = CellResizeMode.Resized;
        }

        public GridCell(int row, int col, int rowSpan, int colSpan)
            : base()
        {
            this.Row = row;
            this.Col = Col;
            this.RowSpan = rowSpan;
            this.ColSpan = colSpan;
        }

        #endregion
        #region props

        /// <summary>
        /// Gets or sets the delay before the tranisiton starts. Allowed values are between 0 and Grid.MaxLevel.
        /// </summary>
        public int StartDelay { get; set; }

        /// <summary>
        /// Gets or sets the offset when the tranisiton stops before the whole transition completes. Allowed values are between 0 and Grid.MaxLevel.
        /// </summary>
        public int StopDelay { get; set; }

        /// <summary>
        /// Gets or sets the row where this cell begins.
        /// </summary>
        public int Row { get; set; }

        /// <summary>
        /// Gets or sets the column where this cell begins.
        /// </summary>
        public int Col { get; set; }

        /// <summary>
        /// Gets or sets how many rows this cell spans.
        /// </summary>
        public int RowSpan { get; set; }

        /// <summary>
        /// Get or sets how may rows this cell spans.
        /// </summary>
        public int ColSpan { get; set; }

        public float RotateX { get; set; }
        public float RotateY { get; set; }
        public float RotateZ { get; set; }

        /// <summary>
        /// Gets or sets the alpha value for the cell
        /// </summary>
        public int Alpha
        {
            get { return alpha; }
            set { ValidateAlpha(value); if (value != alpha) { alpha = value; } }
        }

        /// <summary>
        /// Gets or sets how to scale a control associated with this cell.
        /// </summary>
        public CellResizeMode ResizeMode { get; set; }

        /// <summary>
        /// Gets or sets whether the cell is scaled to a minimum of 1 pixel.
        /// </summary>
        public bool Minimized { get; set; }

        #endregion
        #region methods

        private static void ValidateAlpha(int value)
        {
            if (value < 0 || value > 255) throw new ArgumentOutOfRangeException("Alpha must be between 0 and 255.");
        }

        #endregion
    }

    /// <summary>
    /// Specifies how to scale a control assoicated with a cell.
    /// </summary>
    public enum CellResizeMode
    {
        /// <summary>
        /// Resizes the cell this is the default mode.
        /// </summary>
        Resized,

        /// <summary>
        /// Scales from the center.
        /// </summary>
        Centered,

        /// <summary>
        /// Scale from the top left offset.
        /// </summary>
        Stretched

    }

}
